#pragma once
#include <iostream>
#include <cmath>
#define M_PI 3.14159265358979323846f
using namespace std;

class TPoint {
public:
	float x, y;
public:
	TPoint(float a, float b) {x=a;y=b;}
	TPoint(){x=y=0;}

	TPoint operator+(TPoint& b) {return TPoint(x+b.x, y+b.y);}
	TPoint operator-(TPoint& b) {return TPoint(x-b.x, y-b.y);}
	TPoint operator-(void) {return TPoint(-x,-y);}
	TPoint operator*(float s) {return TPoint(x*s, y*s);}
	friend std::ostream& operator<<(std::ostream& os, TPoint& b){
		return os << b.x << " " << b.y;
	}
	TPoint antiClockwiseRotate(void) {
		return TPoint(-y, x);
	}
	TPoint clockwiseRotate(void) {
		return TPoint(y, -x);
	}
	TPoint rotate(float alpha) {
		alpha = alpha/180*M_PI;
		return TPoint(x*cos(alpha)-y*sin(alpha), x*sin(alpha)+y*cos(alpha));
	}
	TPoint normizeTo(float len) {
		return (*this)*(len/norm());
	}

	float norm(void) {return sqrt(x*x + y*y);}
	float cross(TPoint b) {return x*b.y - y*b.x;}
	float dot(TPoint b) {return x*b.x + y*b.y;}
	float dis(TPoint b) {
		float e1 = b.dot(this->normizeTo(1));
		float e2 = b.norm();
		return sqrt(e2*e2 - e1*e1);
	}

	float angel(void) {
		return angel(TPoint(0, -100));
	}

	float angel(TPoint v) {
		float deg = asin(cross(v) / (norm()*v.norm()));
		if (dot(v) < 0) {
			if (deg < 0)
				deg = -M_PI - deg;
			else
				deg = M_PI - deg;
		}
		return -deg*180/M_PI;
	}
};
